package com.vhall.autotest.api_test.service.cloudwise;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Assert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.vhall.autotest.api_test.common.Constant;
import com.vhall.autotest.api_test.common.ConstantCloudwise;
import com.vhall.autotest.api_test.common.Http;
import com.vhall.autotest.api_test.common.Http_new;
import com.vhall.autotest.api_test.service.code.ICode;
import com.vhall.autotest.api_test.service.code.IWebinarCode;

public class ModifiedUser implements IWebinarCode{
	static String user_id = "17";

	/*
	 * 修改用户
	 * 2016-5-25
	 */
	public static String createUser_success(String user_email,String user_name,String user_psw,String user_roles,String organization,String user_tel,String country,String user_qq,String user_id) {
		Http http = new Http();
		String createUserUrl = Constant.apiDomain + "/v2/user/modify/"+user_id+".json?access_token="+	GetToken.getToken_success(ConstantCloudwise.grant_type, ConstantCloudwise.username, ConstantCloudwise.password, ConstantCloudwise.client_id, ConstantCloudwise.client_secret);
				Map<String, String> param = new HashMap<String, String>();
				param.put("user_email", user_email);
				param.put("user_name", user_name);
				param.put("user_psw", user_psw);
				param.put("user_roles", user_roles);
				param.put("organization", organization);
				param.put("user_tel", user_tel);
				param.put("country", country);
				param.put("user_qq", user_qq);
				String data = JSON.toJSON(param).toString();
				Map<String, String> param1 = new HashMap<String, String>();
				param1.put("user_id", user_id);
				param1.put("data", data);
				System.out.println("param:" + param1);
				Map<String, String> result;
				try {
					result = http.post(createUserUrl, param1);
					String statusCode = result.get("statusCode");
					String resultText = result.get("resultText");
					System.out.println("statusCode:" + statusCode);
					Assert.assertNotNull(statusCode);
					Assert.assertNotNull(resultText);
					Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
					JSONObject obj = JSONObject.parseObject(resultText);
					System.out.println(obj);
					Assert.assertTrue(obj.containsKey("200"));
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
					return null;
			} 
			

	public static void main(String[] args) {
//		CreatUser.getUserLists_success(GetToken.getToken_success(ConstantCloudwise.grant_type, ConstantCloudwise.username, ConstantCloudwise.password, ConstantCloudwise.client_id, ConstantCloudwise.client_secret));
		ModifiedUser.createUser_success("123testpost1@163.com", "sunwy2", "123456", "3", "8","13511111111","CN","","17");
	}
}


class ModifyUser{
	private String user_name;
	private String user_email;
	private String user_psw;
	private String user_roles;
	private String user_tel;
	private String user_qq;
	private String countey;
	private String organization;
	public String getUser_name() {
		return user_name;
	}
	public void setUser_name(String user_name) {
		this.user_name = user_name;
	}
	public String getUser_email() {
		return user_email;
	}
	public void setUser_email(String user_email) {
		this.user_email = user_email;
	}
	public String getUser_psw() {
		return user_psw;
	}
	public void setUser_psw(String user_psw) {
		this.user_psw = user_psw;
	}
	public String getUser_roles() {
		return user_roles;
	}
	public void setUser_roles(String user_roles) {
		this.user_roles = user_roles;
	}
	public String getUser_tel() {
		return user_tel;
	}
	public void setUser_tel(String user_tel) {
		this.user_tel = user_tel;
	}
	public String getUser_qq() {
		return user_qq;
	}
	public void setUser_qq(String user_qq) {
		this.user_qq = user_qq;
	}
	public String getCountey() {
		return countey;
	}
	public void setCountey(String countey) {
		this.countey = countey;
	}
	public String getOrganization() {
		return organization;
	}
	public void setOrganization(String organization) {
		this.organization = organization;
	}
	
	
	
}
